#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
 struct ListNode {
    int val;
    struct ListNode* next;
};

    struct ListNode* reverseList(struct ListNode* head) {
        if (head == NULL)
            return NULL;
        else {
            struct ListNode* cur = head->next;
            head->next = NULL;
            while (cur != NULL) {
                struct ListNode* n = cur->next;
                cur->next = head;
                head = cur;
                cur = n;
            }
        }
        return head;
    }
